<?php
import('@.Common.Account');
class AdminAccount extends Account{
    //单体模式
    static protected $me= null;
    static public function &get(){
        if (! self::$me){
            self::$me= new AdminAccount();
        }
        return self::$me;
    }
    
    private $admin;
    /****
    * 根据uid获取管理权限
    */
    public function getAdmin($uid=null){
        if (! $this->admin){
            if (!isset($uid)){
                $uid= $this->isLogged();
            }
            if (!$uid){
                return $this->admin= null;
            }
            $am= new AdminModel();
            $this->admin= $am->find($uid);
        }
        return $this->admin;
    }
    public function allow($type){
        $a= $this->getAdmin();
        if ($a['allow_'.$type]){
            return true;
        } else{
            return false;
        }
    }
}